package com.learn.demo.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

public class HttpServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        //获取管道
        ChannelPipeline pipeline = ch.pipeline();
        //HttpServerCodec是netty提供处理HTTP的编-解码器
        pipeline.addLast("HttpServerCodecDemo", new HttpServerCodec());
        //增加自定义handler
        pipeline.addLast("HttpServerHandlerDemo", new HttpServerHandlerDemo());
    }
}
